package com.gimi.cloud.bbp.client.controller.mall;

import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.gimi.cloud.bbp.client.service.mall.MallCartService;
import com.gimi.cloud.bbp.common.utils.reqhead.Util;
import com.gimi.cloud.bbp.dto.mall.MallCartDTO;

/**
 * 购物车服务
 * @author 李林峰
 */
@RestController
@RequestMapping(value = "/mall/cart")
public class MallCartController {
	@Autowired private MallCartService mallCartService;
	
	@RequestMapping(value = "/addGoodsToShoppingCart")
	public void addGoodsToShoppingCart(@RequestBody MallCartDTO mallCart,HttpServletResponse response) {
		Util.sendResponse(JSON.toJSONString(mallCartService.addGoodsToShoppingCart(mallCart)),response);
	}
	
	@RequestMapping(value = "/showShoppingCart")
	public void showShoppingCart(@RequestBody MallCartDTO mallCart,HttpServletResponse response) {
		Util.sendResponse(JSON.toJSONString(mallCartService.showShoppingCart(mallCart)),response);
	}
	
	@RequestMapping(value = "/updateShoppingCart")
	public void updateShoppingCart(@RequestBody MallCartDTO mallCart,HttpServletResponse response) {
		Util.sendResponse(JSON.toJSONString(mallCartService.updateShoppingCart(mallCart)),response);
	}
	
	@RequestMapping(value = "/deleteShoppingCart")
	public void deleteShoppingCart(@RequestBody JSONObject mallCart,HttpServletResponse response) {
		Util.sendResponse(JSON.toJSONString(mallCartService.deleteShoppingCart(mallCart)),response);
	}
	
}